<template>
	<view>
		<u-action-sheet :list="list" v-model="show" @click="addClick"></u-action-sheet>
	</view>
</template>

<script>
	export default {
		name: "RecordTypeSelect",
		props: {
			children: {
				type: Object,
				default () {
					return null;
				}
			}
		},
		data() {
			return {
				list: [ {
					text: '体温'
				}, {
					text: '饮食' 
				},{
					text: '如厕' 
				}, {
					text: '睡眠' 
				},
				{
					text: '更多',
				}],
				show: false
			};
		},
		methods:{
			open() {
				this.show = true;
			},
			addClick(index) {
				if (index === 0) {
					// this.suckleClick();
					this.temperatureClick();
				} else if (index === 1) {
					// this.defecationClick('');
					this.foodClick();
				} else if (index === 2) {
					// this.temperatureClick();
					this.defecationClick();
				} else if (index === 3) {
					// this.defecationClick(true);
							this.sleepClick();
				} else if (index === 4) {
					this.suckleClick();
				} else if (index === 5) {
					// this.foodClick();
				}
			},
			
			suckleClick(params) {
				this.$u.route({
					url: 'pages_sub/record/suckle-page',
					params: {
						...this.children,
						...params
					}
				})
			},
			
			defecationClick(diaper, params) {
				if (!this.$u.test.isEmpty(this.children)){
					this.children.diaper = diaper;
				}
				this.$u.route({
					url: 'pages_sub/record/defecation-page',
					params: {
						...this.children,
						...params
					}
				})
			},
			
			temperatureClick(params) {
				this.$u.route({
					url: 'pages_sub/record/temperature-page',
					params: {
						...this.children,
						...params
					}
				})
			},
			
			sleepClick(params) {
				this.$u.route({
					url: 'pages_sub/record/sleep-page',
					params: {
						...this.children,
						...params
					}
				})
			},
			
			foodClick(params) {
				this.$u.route({
					url: 'pages_sub/record/food-page',
					params: {
						...this.children,
						...params
					}
				})
			},
		}
	}
</script>

<style lang="scss">
</style>

